﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lazy
{
    class Program
    {
        static void Main(string[] args)
        {
            Person[] pers = new Person[6];
            pers[0] = new Teacher("嫦娥");
            for (int i = 1; i < pers.Length; i++)
            {
                pers[i] = new Student($"学生{i}号", i);
            }
            Student.Teacher.SayHello();
            for (int i = 1; i < pers.Length; i++)
            {
                pers[i].SayHello();
            }
            Student.Teacher = (Teacher)pers[0];
            for (int i = 0; i < pers.Length; i++)
            {
                pers[i].SayHello();
            }
        }
    }

    public abstract class Person
    {
        private string name;

        protected Person()
        {
        }

        protected Person(string name)
        {
            Name = name;
        }

        public string Name { get => name; set => name = value; }

        public abstract void SayHello();
    }
    public class Student : Person
    {
        private int stuNum;
        private static Teacher teacher;

        public Student()
        {
        }

        public Student(string name, int stuNum) : base(name)
        {
            this.StuNum = stuNum;
        }

        static Student()
        {
            Teacher = new Teacher("唐僧");
        }

        public int StuNum { get => stuNum; set => stuNum = value; }
        public static Teacher Teacher { get => teacher; set => teacher = value; }

        public override void SayHello()
        {
            Console.WriteLine($"My name is {this.Name},My Num is {this.StuNum},My teacher is {Teacher}");
        }
    }

    public class Teacher : Person
    {
        public Teacher()
        {
        }

        public Teacher(string name) : base(name)
        {
        }

        public override void SayHello()
        {
            Console.WriteLine($"i am a teacher,my name is {this.Name}");
        }

        public override string ToString()
        {
            return this.Name;
        }
    }
}
